<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../template/WorkspaceTemplate.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:define name="top">

    </ui:define>

    <ui:define name="left">

    </ui:define>

    <ui:define name="right">

    </ui:define>

    <ui:define name="content">
        <style>
            .ui-datatable table {
                text-align: center;
                border-collapse: collapse;
                width: 100%;
                border-color: grey;
                background-color: white;
            }
            .ui-datatable table td{
                padding: 5px 2px 10px;
                width: 45px;
            }
            .ui-datatable table th{
                height: 30px;
                width: 30px;
            }
            .ui-datatable .ui-datatable-header, .ui-datatable .ui-datatable-footer {
                text-align: center;
                padding: 4px 10px 4px 160px;
            }
            .ui-inputfield, .ui-widget-content .ui-inputfield, .ui-widget-header .ui-inputfield {
                width: 60px;
            }
        </style>
        <h:form id="dmpsInfoForm">
            <p:panel header="Daily Master Productin Schedule Basic Information">
                <p:messages showDetail="true"/>
                <h:panelGrid columns="4">
                    <h:outputLabel style="font-weight: bold" value="Date Created: "/>
                    <h:outputText value="#{dailyMpsViewManagerBean.selectedMPS.formattedDay}"/>
                    <h:outputText value=""/>
                    <h:outputText value=""/>


                </h:panelGrid>
            </p:panel>
        </h:form>
        <h:form id="dmpsForm">
            <div style="border:1px solid gray;width:700px;overflow-y:hidden;overflow-x:scroll;">
                <div class="ui-datatable ui-widget">
                    <table border="1" summary="for all products">
                        <caption>
                            <div class="ui-datatable-header ui-widget-header ui-corner-tl ui-corner-tr">
                                Daily Master Production Schedule
                            </div>
                        </caption>

                        <tbody class="ui-datatable-data">
                            <tr>
                                <th class="ui-state-default" colspan="2" rowspan="5">Monthly Demand</th>
                            </tr>
                            <c:forEach items="#{dailyMpsViewManagerBean.counterForProduct}" var="item">
                                <tr>
                                    <th class="ui-state-default"><h:outputText value="#{dailyMpsViewManagerBean.returnProductAlpha(item)}" /></th>
                                    <td colspan="10"><h:outputText value="#{dailyMpsViewManagerBean.monthlyDemands.get(item)}"/></td>
                                </tr>
                            </c:forEach>

                            <tr>
                                <th class="ui-state-default" colspan="2">Working Days</th>
                                <th class="ui-state-default"></th>
                                <td colspan="10"><h:outputText value="#{dailyMpsViewManagerBean.totalWorkingDays}"/></td>
                            </tr>

                            <tr>
                                <th class="ui-state-default" colspan="2">Daily MPS</th>
                                <th class="ui-state-default"></th>
                                <c:forEach items="#{dailyMpsViewManagerBean.times}" var="item">
                                    <td colspan="2"><h:outputText value="#{dailyMpsViewManagerBean.returnFormattedDay(item)}"/></td>
                                </c:forEach>
                            </tr>

                            <tr>
                                <th class="ui-state-default" colspan="2"></th>
                                <th class="ui-state-default"></th>
                                <c:forEach items="#{dailyMpsViewManagerBean.counterForWeek}" var="item">
                                    <td colspan="2">Total</td>
                                </c:forEach>
                            </tr>

                            <tr>
                                <th class="ui-state-default" colspan="2"></th>
                                <th class="ui-state-default"></th>
                                <c:forEach items="#{dailyMpsViewManagerBean.counterForWeek}" var="item">
                                    <td>Cases</td>
                                    <td>hrs</td>
                                </c:forEach>
                            </tr>


                            <tr>
                                <th class="ui-state-default" colspan="2" rowspan="5">Daily Demand(Normal)</th>
                            </tr>
                            <c:forEach items="#{dailyMpsViewManagerBean.counterForProduct}" var="item">
                                <tr>
                                    <th class="ui-state-default"><h:outputText value="#{dailyMpsViewManagerBean.returnProductAlpha(item)}" /></th>
                                    <c:forEach items="#{dailyMpsViewManagerBean.counterForWeek}" var="counter">
                                        <td><h:outputText value="#{dailyMpsViewManagerBean.dailyDemands.get(item).get(counter)}" /></td>
                                        <td><h:outputText value="#{dailyMpsViewManagerBean.returnDailyDemandInHours(dailyMpsViewManagerBean.dailyDemands.get(item).get(counter), item)}">
                                                <f:convertNumber pattern="#.##"/>
                                            </h:outputText></td>
                                    </c:forEach>
                                </tr>
                            </c:forEach>

                            <tr>
                                <th class="ui-state-default" colspan="2">Capacity with Normal Shift</th>
                                <th class="ui-state-default"></th>
                                <c:forEach items="#{dailyMpsViewManagerBean.counterForWeek}" var="counter">
                                    <th></th>
                                    <td><h:outputText value="#{dailyMpsViewManagerBean.returnNormalShift()}"/></td>
                                </c:forEach>
                            </tr>

                            <tr>
                                <th class="ui-state-default" colspan="2">Utilization with Normal Shift</th>
                                <th class="ui-state-default"></th>
                                <c:forEach items="#{weeklyMpsManagerBean.counterForWeek}" var="counter">
                                    <th></th>
                                    <td><h:outputText value="#{dailyMpsViewManagerBean.returnUtilizationNormalShift(counter)}">
                                            <f:convertNumber type="percent" />
                                        </h:outputText></td>
                                </c:forEach>
                            </tr>

                            <tr>
                                <th class="ui-state-default" colspan="2" rowspan="5">Daily Demand(Overtime)</th>
                            </tr>
                            <c:forEach items="#{dailyMpsViewManagerBean.counterForProduct}" var="item">
                                <tr>
                                    <th class="ui-state-default"><h:outputText value="#{dailyMpsViewManagerBean.returnProductAlpha(item)}" /></th>
                                    <c:forEach items="#{dailyMpsViewManagerBean.counterForWeek}" var="counter">
                                        <td><h:outputText value="#{dailyMpsViewManagerBean.dailyOTDemands.get(item).get(counter)}" /></td>
                                        <td><h:outputText value="#{dailyMpsViewManagerBean.returnDailyDemandInHours(dailyMpsViewManagerBean.dailyOTDemands.get(item).get(counter), item)}">
                                                <f:convertNumber pattern="#.##"/>
                                            </h:outputText></td>
                                    </c:forEach>
                                </tr>
                            </c:forEach>

                            <tr>
                                <th class="ui-state-default" colspan="2">Capacity with Overtime Shift</th>
                                <th class="ui-state-default"></th>
                                <c:forEach items="#{dailyMpsViewManagerBean.counterForWeek}" var="counter">
                                    <th></th>
                                    <td><h:outputText value="#{dailyMpsViewManagerBean.returnOvertimeShift()}"/></td>
                                </c:forEach>
                            </tr>

                            <tr>
                                <th class="ui-state-default" colspan="2">Utilization with Overtime Shift</th>
                                <th class="ui-state-default"></th>
                                <c:forEach items="#{weeklyMpsManagerBean.counterForWeek}" var="counter">
                                    <th></th>
                                    <td><h:outputText value="#{dailyMpsViewManagerBean.returnUtilizationOvertimeShift(counter)}">
                                            <f:convertNumber type="percent" />
                                        </h:outputText></td>
                                </c:forEach>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </h:form>
        <h:form id="legend">
            <p:panel>
                <h:panelGrid columns ="8">
                    <c:forEach items="#{dailyMpsViewManagerBean.counterForProduct}" var="item">
                        <h:outputText value="#{dailyMpsViewManagerBean.returnProductAlpha(item)}" />
                        <h:outputText value="#{dailyMpsViewManagerBean.returnProductName(item)}"/>
                        <h:outputLabel value=""/>
                        <h:outputLabel value=""/>
                    </c:forEach>
                </h:panelGrid>
            </p:panel>
        </h:form>
        <p:dialog id="scheduleDialog" widgetVar="scheduleDlg" header="View computer-generated schedule" showEffect="explode" hideEffect="explode">
            <h:form id="scheduleForm">
                <h:outputLink id="lnk" value="#" style="right: 250px">  
                    <p:printer target="scheduleForm" />  
                    <p:graphicImage value="/images/print.png" height="45px" width="45px"/>  
                </h:outputLink>
            </h:form>
        </p:dialog>
    </ui:define>

    <ui:define name="bottom">

    </ui:define>

</ui:composition>
